import 'package:encrypt_and_decrypt_files/encrypt_page/encrypt_decrypt_page.dart';
import 'package:encrypt_and_decrypt_files/widget/extension.dart';
import 'package:encrypt_and_decrypt_files/widget/theme_provider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class HistoryDetailPage extends StatefulWidget {
  const HistoryDetailPage({super.key, required this.detailModel});

  final RecordProcessingModel detailModel;

  @override
  // ignore: library_private_types_in_public_api
  _HistoryDetailPageState createState() => _HistoryDetailPageState();
}

class _HistoryDetailPageState extends State<HistoryDetailPage>
    with SingleTickerProviderStateMixin {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final themeProvider = Provider.of<ThemeProvider>(context);

    return Scaffold(
      appBar: AppBar(
        title: Text('History Detail'.t(context)),
        backgroundColor: themeProvider.mainColor,
      ),
      body: Column(
        children: [
          _buildEveryItem('type'.t(context), widget.detailModel.type ?? ''),
          _buildEveryItem(
              'originDir'.t(context), widget.detailModel.originDir ?? ''),
          _buildEveryItem(
              'originFile'.t(context), widget.detailModel.originFile ?? ''),
          _buildEveryItem(
              'destDir'.t(context), widget.detailModel.destDir ?? ''),
          _buildEveryItem(
              'destFile'.t(context), widget.detailModel.destFile ?? ''),
          _buildEveryItem(
              'algorithm'.t(context), widget.detailModel.algorithm ?? ''),
          _buildEveryItem('key name'.t(context), widget.detailModel.name ?? ''),
          _buildEveryItem('key'.t(context), widget.detailModel.key ?? ''),
          _buildEveryItem(
              'dateTime'.t(context), widget.detailModel.dateTime ?? ''),
        ],
      ),
    );
  }

  Widget _buildEveryItem(String title, String content) {
    return Container(
      padding: const EdgeInsets.only(top: 16, right: 16, bottom: 16),
      child: Row(
        children: [
          Text('$title:'),
          const SizedBox(width: 8),
          Expanded(child: Text(content)),
        ],
      ),
    );
  }
}
